module.exports = (app) => {
  const { STRING, INTEGER, DATE, JSON } = app.Sequelize;

  const Directory = app.model.define(
    "directory",
    {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
      },
      name: {
        type: STRING(100),
        allowNull: false,
      },
      parentId: {
        type: INTEGER,
        allowNull: false,
        defaultValue: 0,
      },
      level: {
        type: INTEGER,
        defaultValue: 1,
        validate: {
          max: 3,
        },
      },
      createdAt: {
        type: DATE,
      },
      updatedAt: {
        type: DATE,
      },
      status: {
        type: INTEGER,
        defaultValue: 0,
      },
      order: {
        type: INTEGER,
        defaultValue: 0,
      },

      creator: {
        type: STRING(255),
        defaultValue: "system"
      }


    },
    {
      timestamps: true,
      underscored: false,
    }
  );

  return Directory;
};
